/*
 * Copyright 2007-2010 Jeremy Brown.
 *
 * Licensed under the Apache License, Version 2.0 (the "License")
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/**
 * @author <a href="http://jeremy-brown.com">Jeremy Brown</a>
 */


package groovy.prefuse.factory

import prefuse.Visualization
import prefuse.visual.VisualTable
import prefuse.data.Table
import prefuse.data.Graph
import prefuse.data.io.*

public class VisualTableFactory extends AbstractFactory
{
	boolean isLeaf()
	{
		return false
	}
    
    public Object newInstance(FactoryBuilderSupport builder, Object name, Object value, Map attributes) throws InstantiationException, IllegalAccessException
	{
		VisualTable visualTable = null
		
		//Use a visualTable when you want to add new columns of data that are not in the data table but are instead calculated on the fly at runtime.
		//A visualTable could be declared as a sibling to a table. The table should be declared with a visualID attribute that is handed to the visualTable. e.g.
		//prefuse.pfVisualization(id:"viz")
		//{
		//	pfTable(file:"BookPriceData.txt", hasHeader:true, id:"bookTable", visualID:"bookVisualTable")
		//	pfVisualTable(bookVisualTable)
		//	{
		//		pfColumn("ExpensiveBook", "Price > 500")
		//	}
		//}
		//This example would load a file called BookPriceData.txt with its data columns. A VisualTable called bookVisualTable is declared in the table declaration.
		//This is then used in the pfVisualTable() declaration, which adds a new data column that includes only books with a Price > 500.
		//(The "Price" field is assumed to be in the BookPriceData.txt file.)
		//Later on, books with "true" in the ExpensiveBook column could be shown in red, or with a different shape.
				
		//A VisualTable object should be passed in as the value, simply return it
		if(value instanceof VisualTable)
		{
			visualTable = value
		}

		return visualTable
    }
}
